package control;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.RequestContext;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.servlet.ServletRequestContext;



import util.Info;

import dao.CommDAO;

public class MainCtrl extends HttpServlet {

	public MainCtrl() {
		super();
	}

	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException {
	this.doPost(request, response);
	}

		public void go(String url,HttpServletRequest request, HttpServletResponse response)
		{
		try {
			request.getRequestDispatcher(url).forward(request, response);
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		}
		
		public void gor(String url,HttpServletRequest request, HttpServletResponse response)
		{
			try {
				response.sendRedirect(url);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
		}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
        response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		HttpSession session = request.getSession();
		HashMap user = (HashMap)session.getAttribute("admin");
		HashMap yz = (HashMap)session.getAttribute("yz");
		String ac = request.getParameter("ac");
		if(ac==null)ac="";
		CommDAO dao = new CommDAO();
		String date = Info.getDateStr();
		String today = date.substring(0,10);
		String tomonth = date.substring(0,7);
		
		//登录
		if(ac.equals("login"))
		{
			    String uname = request.getParameter("uname");
			    String upass = request.getParameter("upass");
			    	String sql = "select * from sysuser where uname='"+uname+"' and upass='"+upass+"' and utype='0'";
			    	List<HashMap> list = dao.select(sql);
			    	if(list.size()==1)
			    	{
			    	session.setAttribute("admin", list.get(0));
			    	gor("/wuyegl/admin/main.jsp", request, response);
			    	}else{
			    		request.setAttribute("error", "");
				    	go("/admin/login.jsp", request, response);
			    	}
		}
		
		//登录
		if(ac.equals("login1"))
		{
			    String uname = request.getParameter("uname");
			    String upass = request.getParameter("upass");
			    	String sql = "select * from sysuser where uname='"+uname+"' and upass='"+upass+"' and utype='1'";
			    	List<HashMap> list = dao.select(sql);
			    	if(list.size()==1)
			    	{
			    	session.setAttribute("yz", list.get(0));
			    	gor("/wuyegl/welcome.jsp", request, response);
			    	}else{
			    		request.setAttribute("error", "");
				    	go("/welcome.jsp", request, response);
			    	}
		}
		
		//退出登录
		if(ac.equals("exit"))
		{
			   session.invalidate();
			    	
			    	
			    	gor("/wuyegl/welcome.jsp", request, response);
			    	
			    	
		}
		
		//修改密码
		if(ac.equals("uppass"))
		{
			    String oldpass = request.getParameter("oldpass");  
			    String upass = request.getParameter("upass");
			    if(!user.get("upass").equals(oldpass))
			    {
			    	request.setAttribute("error", "");
			    	go("/admin/uppass.jsp", request, response);
			    }else{
			    	String sql = "update sysuser set upass='"+upass+"' where id="+user.get("id");
			    	dao.commOper(sql);
			    	request.setAttribute("suc", "");
			    	go("/admin/uppass.jsp", request, response);
			    }
		}
		
		//添加房产
		if(ac.equals("addhousees"))
		{
			    String dong = request.getParameter("dong");  
			    String danyuan = request.getParameter("danyuan");
			    String cen = request.getParameter("cen");
			    String hao = request.getParameter("hao");
			    String shi = request.getParameter("shi");
			    String ting = request.getParameter("ting");
			    String chu = request.getParameter("chu");
			    String wei = request.getParameter("wei");
			    String mianji = request.getParameter("mianji");
			    String status ="0";
			    String uid = "";
			    String rztime = "";
			    String qctime = "";
			    String sql = "insert into house values(null,'"+dong+"','"+danyuan+"','"+cen+"','"+hao+"','"+shi+"','"+ting+"','"+chu+"','"+wei+"'" +
			    		",'"+mianji+"','"+status+"','"+uid+"','"+rztime+"','"+qctime+"')";
			    System.out.println(sql);
			    dao.commOper(sql);
		    	request.setAttribute("suc", "");
		    	go("/admin/addhousees.jsp", request, response);
		}
		
		//修改房产
		if(ac.equals("updatehousees"))
		{
			String id = request.getParameter("id"); 
			String dong = request.getParameter("dong");  
		    String danyuan = request.getParameter("danyuan");
		    String cen = request.getParameter("cen");
		    String hao = request.getParameter("hao");
		    String shi = request.getParameter("shi");
		    String ting = request.getParameter("ting");
		    String chu = request.getParameter("chu");
		    String wei = request.getParameter("wei");
		    String mianji = request.getParameter("mianji");
			    String sql = "update house set dong='"+dong+"',danyuan='"+danyuan+"',cen='"+cen+"',hao='"+hao+"',shi='"+shi+"',ting='"+ting+"',chu='"+chu+"',wei='"+wei+"',mianji='"+mianji+"' where id="+id;
			    dao.commOper(sql);
		    	request.setAttribute("suc", "");
		    	go("/admin/addhousees.jsp", request, response);
		}
		
		
		//添加员工
		if(ac.equals("addemps"))
		{
			    String truename = request.getParameter("truename");  
			    String empno = request.getParameter("empno");
			    String sex = request.getParameter("sex");
			    String addr = request.getParameter("addr");
			    String sfid = request.getParameter("sfid");
			    String telphone = request.getParameter("telphone");
			    String sql = "insert into emps values(null,'"+truename+"','"+empno+"','"+sex+"','"+addr+"','"+sfid+"','"+telphone+"')";
			    dao.commOper(sql);
		    	request.setAttribute("suc", "");
		    	go("/admin/addemps.jsp", request, response);
		}
		
		//修改员工
		if(ac.equals("updateemps"))
		{
			String id = request.getParameter("id");
			    String truename = request.getParameter("truename");  
			    String empno = request.getParameter("empno");
			    String sex = request.getParameter("sex");
			    String addr = request.getParameter("addr");
			    String sfid = request.getParameter("sfid");
			    String telphone = request.getParameter("telphone");
			    String sql = "update emps set truename='"+truename+"',empno='"+empno+"',sex='"+sex+"',addr='"+addr+"',sfid='"+sfid+"',telphone='"+telphone+"' where id="+id;
			    dao.commOper(sql);
		    	request.setAttribute("suc", "");
		    	go("/admin/addemps.jsp", request, response);
		}
		
		//添加车位
		if(ac.equals("addcw"))
		{
			    String cwno = request.getParameter("cwno");  
			    String addr = request.getParameter("addr");
			    String status = "0";
			    String uid = "";
			    String sql = "insert into cw values(null,'"+cwno+"','"+addr+"','"+status+"','"+uid+"')";
			    dao.commOper(sql);
		    	request.setAttribute("suc", "");
		    	go("/admin/x-addcw.jsp", request, response);
		}
		//添加车位
		if(ac.equals("upcw"))
		{
			String id = request.getParameter("id");
			    String cwno = request.getParameter("cwno");  
			    String addr = request.getParameter("addr");
			    String sql = "update cw set cwno='"+cwno+"',addr='"+addr+"' where id="+id;
			    dao.commOper(sql);
		    	request.setAttribute("suc", "");
		    	go("/admin/x-upcw.jsp", request, response);
		}
		//根据楼号得到房号
		if(ac.equals("gethouses"))
		{
			String louno = request.getParameter("louno");
			   String sql = "select * from housees where louno='"+louno+"'";
			    List<HashMap> list =  dao.select(sql);
		    	String h = "";
		    	for(HashMap m:list)
		    	{
		    		h+= m.get("houseno")+"-";
		    	}
		    	if(h.length()>0)h=h.substring(0,h.length()-1);
		    	out.print(h);
		}
		
		//用户注册
		if(ac.equals("adduser"))
		{
			    String uname = request.getParameter("uname");  
			    
			    String csql = "select * from sysuser where uname='"+uname+"'";
			    if(dao.select(csql).size()>0)
			    {
			    	request.setAttribute("error", "");
			    	go("/admin/adduser.jsp", request, response);
			    }else{
			    String upass = request.getParameter("upass");
			    String truename = request.getParameter("truename");
			    String houseno = request.getParameter("houseno");
			    String sfid = request.getParameter("sfid");
			    String phone = request.getParameter("phone");
			    String rztime = Info.getDateStr();
			    String ss = "";
			    String sql = "insert into sysuser values(null,'"+uname+"','"+upass+"','"+1+"','"+truename+"','"+houseno+"','"+sfid+"','"+phone+"')";
			    dao.commOper(sql);
			    if(!houseno.equals("")){
			    ss = "update house set status=1,rztime='"+rztime+"',qctime='' where id="+houseno;
			    dao.commOper(ss);
			    }
		    	request.setAttribute("suc", "");
		    	go("/admin/adduser.jsp", request, response);
			    }
		}
		
		//修改用户
		if(ac.equals("updateuser"))
		{
			    String id = request.getParameter("id");
			    String hid = request.getParameter("hid");
			    String uname = request.getParameter("uname");  
			    String upass = request.getParameter("upass");
			    String truename = request.getParameter("truename");
			    String houseno = request.getParameter("houseno");
			    String sfid = request.getParameter("sfid");
			    String phone = request.getParameter("phone");
			    String sql = "update sysuser set uname='"+uname+"',upass='"+upass+"',truename='"+truename+"',houseno='"+houseno+"',sfid='"+sfid+"',phone='"+phone+"' where id="+id;
			    
			    String ssql = "select * from wyf where status='0' and uid="+id;
			    ArrayList<HashMap> lll = (ArrayList)dao.select(ssql);
			    if(lll.size()==0){
			    	dao.commOper(sql);
			    if(!hid.equals("")){
			    if(houseno.equals("")){
			    	String s = "update house set status=0,qctime='"+Info.getDateStr()+"' where id="+hid;
			    	dao.commOper(s);
			    }else{
			    	String ss = "update house set status=1,rztime='"+Info.getDateStr()+"',qctime='' where id="+houseno;
			    	String sss = "update house set status=0,qctime='"+Info.getDateStr()+"' where id="+hid;
			    	ArrayList ll = new ArrayList();
			    	ll.add(ss);
			    	ll.add(sss);
			    	dao.commOperSqls(ll);
			    }
			    }else{
			    	String a = "update house set status=1,rztime='"+Info.getDateStr()+"',qctime='' where id="+houseno;
			    	dao.commOper(a);
			    } 
			    
		    	request.setAttribute("suc", "");
		    	request.setAttribute("id", id);
		    	go("/admin/updateuser.jsp?id="+id, request, response);
			    }else{
			    	request.setAttribute("error", "");
			    	go("/admin/updateuser.jsp?id="+id, request, response);
			    	
			    }
		    	
		}
		//用户修改自己信息
		if(ac.equals("updateuser1"))
		{
			    String id = request.getParameter("id");
			    String uname = request.getParameter("uname");  
			    String upass = request.getParameter("upass");
			    String truename = request.getParameter("truename");
			    String sfid = request.getParameter("sfid");
			    String phone = request.getParameter("phone");
			    String sql = "update sysuser set uname='"+uname+"',upass='"+upass+"',truename='"+truename+"',sfid='"+sfid+"',phone='"+phone+"' where id="+id;
			    dao.commOper(sql);
			    
		    	request.setAttribute("suc", "");
		    	request.setAttribute("id", id);
		    	go("/xgxx.jsp?id="+id, request, response);
		}
		//车辆入位
		if(ac.equals("addclrw"))
		{
			    String cwid = request.getParameter("id");
			    String uid = request.getParameter("uid"); 
			    String sql = "update cw set uid='"+uid+"',status='1' where id="+cwid;
			    dao.commOper(sql);
		    	request.setAttribute("suc", "");
		    	go("/admin/x-clrw.jsp?id="+cwid, request, response);
		}
		//物业费设置
		if(ac.equals("upwyfset"))
		{
			    String dj = request.getParameter("dj");
			    int id = 1; 
			    String sql = "update wyfset set dj='"+dj+"' where id=1 ";
			    dao.commOper(sql);
		    	request.setAttribute("suc", "");
		    	go("/admin/x-wyfset.jsp", request, response);
		}
		
		//添加设备
		if(ac.equals("addsebei"))
		{
			    String sbname = request.getParameter("sbname");
			    String sbweiz = request.getParameter("sbweiz");  
			    String bei = request.getParameter("bei");
			    String sql = "insert into sebei values(null,'"+sbname+"','"+sbweiz+"','"+bei+"')";
			    dao.commOper(sql);
		    	request.setAttribute("suc", "");
		    	go("/admin/addsebei.jsp", request, response);
		}
		
		//修改设备
		if(ac.equals("updatesebei"))
		{
			String id = request.getParameter("id");
			    String sbname = request.getParameter("sbname");
			    String sbweiz = request.getParameter("sbweiz");  
			    String bei = request.getParameter("bei");
			    String sql = "update sebei set sbname='"+sbname+"',sbweiz='"+sbweiz+"',bei='"+bei+"' where id="+id;
			    dao.commOper(sql);
		    	request.setAttribute("suc", "");
		    	go("/admin/addsebei.jsp", request, response);
		}
		
		//添加设备维修
		if(ac.equals("addsebeix"))
		{
			    String sebei = request.getParameter("sebei");
			    String wxren = request.getParameter("wxren");
			    String feiyong = request.getParameter("feiyong");  
			    String wxtime = request.getParameter("wxtime");  
			    String sql = "insert into sebeix (sebei,wxren,feiyong,wxtime,type) values('"+sebei+"','"+wxren+"','"+feiyong+"','"+wxtime+"','wx')";
			    dao.commOper(sql);
		    	request.setAttribute("suc", "");
		    	go("/admin/addsebeiwx.jsp", request, response);
		}
	//修改设备维修
	if(ac.equals("updatesebeix"))
	{
		String id = request.getParameter("id");
		    String sebei = request.getParameter("sebei");
		    String wxren = request.getParameter("wxren");
		    String feiyong = request.getParameter("feiyong");  
		    String wxtime = request.getParameter("wxtime");  
		    String sql = "update sebeix set sebei='"+sebei+"',wxren='"+wxren+"',feiyong='"+feiyong+"',wxtime='"+wxtime+"' where id="+id;
		    dao.commOper(sql);
	    	request.setAttribute("suc", "");
	    	go("/admin/upsebeiwx.jsp", request, response);
	}
	
	
	//添加停车位
	if(ac.equals("addstops"))
	{
		    String stopno = request.getParameter("stopno");
		    String weizhi = request.getParameter("weizhi");
		    String jiage = request.getParameter("jiage");  
		    String louno = request.getParameter("louno"); 
		    String houseno = request.getParameter("houseno");   
		    
		    if(houseno==null){
		    	louno="暂未";
		    	houseno="使用";
		    }
		    
		    String sql = "insert into stops values(null,'"+stopno+"','"+weizhi+"','"+jiage+"','"+louno+"','"+houseno+"')";
		    dao.commOper(sql);
	    	request.setAttribute("suc", "");
	    	go("/admin/addstops.jsp", request, response);
	}
	
	
	//修改停车位
	if(ac.equals("updatestops"))
	{
            String id = request.getParameter("id");
		    String stopno = request.getParameter("stopno");
		    String weizhi = request.getParameter("weizhi");
		    String jiage = request.getParameter("jiage");  
		    String louno = request.getParameter("louno"); 
		    String houseno = request.getParameter("houseno");   
		    
		    if(houseno==null){
		    	louno="暂未";
		    	houseno="使用";
		    }
		    
		    String sql = "update stops set stopno='"+stopno+"',weizhi='"+weizhi+"',jiage='"+jiage+"',louno='"+louno+"',houseno='"+houseno+"' where id="+id;
		    dao.commOper(sql);
	    	request.setAttribute("suc", "");
	    	go("/admin/addstops.jsp", request, response);
	}
	
	
	//添加收费
	if(ac.equals("addshoufei"))
	{
		    String uid = request.getParameter("uid");
		    String nian = request.getParameter("nian");  
		    String yue = request.getParameter("yue");   
		    String je = request.getParameter("je"); 
		    String status = "0"; 
		    String type = request.getParameter("type"); 
		    String remark = request.getParameter("remark"); 
		    String sql = "insert into wyf values(null,'"+uid+"','"+nian+"','"+yue+"','"+je+"','"+status+"','"+type+"','"+remark+"')";
		    dao.commOper(sql);
	    	request.setAttribute("suc", "");
	    	go("/admin/addshoufei.jsp", request, response);
	}
	
	
	//修改收费
	if(ac.equals("updateshoufei"))
	{
		String id = request.getParameter("id");
		String uid = request.getParameter("uid");
	    String nian = request.getParameter("nian");  
	    String yue = request.getParameter("yue");   
	    String je = request.getParameter("je"); 
	    String type = request.getParameter("type"); 
	    String remark = request.getParameter("remark"); 
		    String sql = "update wyf set uid='"+uid+"',nian='"+nian+"',yue='"+yue+"',je='"+je+"',type='"+type+"',remark='"+remark+"' where id="+id;
		    dao.commOper(sql);
	    	request.setAttribute("suc", "");
	    	go("/admin/addshoufei.jsp", request, response);
	}
	
	
	//添加报修
	if(ac.equals("addbaoxiu"))
	{
		    String content = request.getParameter("bxcontent");
		    System.out.println("//////////////="+content);
		    String sql = "insert into baoxiu (author,content,cljg,slstatus,savetime) values('"+yz.get("id")+"','"+content+"','','未受理','"+Info.getDateStr()+"')";
		    dao.commOper(sql);
	    	request.setAttribute("suc", "");
	    	go("/list.jsp?t=4", request, response);
	}
	
	//受理报修
	if(ac.equals("updatebaoxiu"))
	{
		    String id = request.getParameter("id");
		    String cljg = request.getParameter("cljg");
		    String sql = "update baoxiu set cljg='"+cljg+"',slstatus='已受理' where id="+id;
		    dao.commOper(sql);
	    	request.setAttribute("suc", "");
	    	go("/admin/updatebaoxiu.jsp?id="+id, request, response);
	}
	
	//评价添加
	if(ac.equals("pjtj"))
	{
		    String id = request.getParameter("id");
		    String pj = request.getParameter("pj");
		    String sql = "insert into pjinfo values(null,'"+id+"','"+pj+"','"+yz.get("id")+"','"+Info.getDateStr()+"')";
		    dao.commOper(sql);
	    	request.setAttribute("suc", "");
	    	go("/updatebaoxiu.jsp?id="+id, request, response);
	}
	
	//留言回复
	if(ac.equals("updatemsg"))
	{
		   String id = request.getParameter("id");
		    String content = request.getParameter("recontent");
		    String sql = "update msg set recontent='"+content+"' where id="+id;
		    dao.commOper(sql);
	    	request.setAttribute("suc", "");
	    	go("/admin/updatemsg.jsp?id"+id, request, response);
	}
	

	//添加留言
	if(ac.equals("addmsg"))
	{
		    String content = request.getParameter("msg");
		    String sql = "insert into msg (author,content,recontent,savetime) values('"+yz.get("id")+"','"+content+"','','"+Info.getDateStr()+"')";
		    dao.commOper(sql);
	    	request.setAttribute("suc", "");
	    	go("/list.jsp?t=9", request, response);
	}
	
	//添加网上缴费
	if(ac.equals("addjf"))
	{
		String frombanks = request.getParameter("frombanks");
		String tobanks = request.getParameter("tobanks");
		String author = user.get("id").toString();
		String jftype = request.getParameter("jftype");
		String feiyong = request.getParameter("feiyong");
		String fromacc = request.getParameter("fromacc");
		String toacc = request.getParameter("toacc");
	    String sql = "insert into wsjf values(null,'"+frombanks+"','"+tobanks+"','"+author+"','"+jftype+"','"+feiyong+"','"+fromacc+"','"+toacc+"')";
	    dao.commOper(sql);
    	request.setAttribute("suc", "");
    	go("/admin/addjf.jsp", request, response);
	}
	
	//修改网上缴费
	if(ac.equals("updatejf"))
	{
		String id = request.getParameter("id");
		String frombanks = request.getParameter("frombanks");
		String tobanks = request.getParameter("tobanks");
		String author = user.get("id").toString();
		String jftype = request.getParameter("jftype");
		String feiyong = request.getParameter("feiyong");
		String fromacc = request.getParameter("fromacc");
		String toacc = request.getParameter("toacc");
	    String sql = "update wsjf set frombanks='"+frombanks+"',tobanks='"+tobanks+"',author='"+author+"',jftype='"+jftype+"',feiyong='"+feiyong+"',fromacc='"+fromacc+"',toacc='"+toacc+"' where id="+id;
	    dao.commOper(sql);
    	request.setAttribute("suc", "");
    	go("/admin/addjf.jsp", request, response);
	}
	
	
	
	
	//修改小区信息
	if(ac.equals("upxqinfo"))
	{
		try {
		String remark = "";
		String area = "";
		String addr = "";
		String img = "";
		String ss = "";
		String fileurl = "";
		request.setCharacterEncoding("utf-8");
		RequestContext  requestContext = new ServletRequestContext(request);
		if(FileUpload.isMultipartContent(requestContext)){
			   DiskFileItemFactory factory = new DiskFileItemFactory();
			   factory.setRepository(new File(request.getRealPath("/upfile/")+"/"));
			   ServletFileUpload upload = new ServletFileUpload(factory);
			   upload.setSizeMax(100*1024*1024);
			   List items = new ArrayList();
			    
			     items = upload.parseRequest(request);
			    
			     remark = ((FileItem) items.get(0)).getString();
			     remark = Info.getUTFStr(remark);
			     area = ((FileItem) items.get(1)).getString();
			     area = Info.getUTFStr(area);
			     
			     addr = ((FileItem) items.get(2)).getString();
			     addr = Info.getUTFStr(addr);
			     ss = ((FileItem) items.get(4)).getString();
			     ss = Info.getUTFStr(ss);
			    
			   
			    FileItem fileItem = (FileItem) items.get(3);
			     if(fileItem.getName()!=null && fileItem.getSize()!=0){
			      File fullFile = new File(fileItem.getName());
			      fileurl = Info.generalFileName(fullFile.getName());
			      File newFile = new File(request.getRealPath("/upfile/")+"/" + fileurl);
			      try {
			       fileItem.write(newFile);
			      } catch (Exception e) {
			       e.printStackTrace();
			      }
			     }else{
			     }
			    }
		
	    String sql1 = "update xqinfo set remark='"+remark+"',area='"+area+"',addr='"+addr+"',img='"+fileurl+"',ss='"+ss+"' where id= 1";
	    String sql2 = "update xqinfo set remark='"+remark+"',area='"+area+"',addr='"+addr+"',ss='"+ss+"' where id= 1";
	    if(!fileurl.equals("")){
	    	dao.commOper(sql1);
	    	}else{
	    		dao.commOper(sql2);
	    	}
    	request.setAttribute("suc", "");
    	go("/admin/x-xqinfo.jsp", request, response);
		} catch (Exception e1) {
			e1.printStackTrace();
			request.setAttribute("error", "");
		     request.getRequestDispatcher("/admin/x-xqinfo.jsp").forward(request, response);
		    }
	}
	//添加公告
	if(ac.equals("addnotice"))
	{
		String title = request.getParameter("title");
		String content = request.getParameter("content");
		String savetime = Info.getDateStr();
	    String sql = "insert into notice values(null,'"+title+"','"+content+"','"+savetime+"')";
	    dao.commOper(sql);
    	request.setAttribute("suc", "");
    	go("/admin/x-addnotice.jsp", request, response);
	}
	//修改公告
	if(ac.equals("upnotice"))
	{
		String id = request.getParameter("id");
		String title = request.getParameter("title");
		String content = request.getParameter("content");
		String savetime = Info.getDateStr();
	    String sql = "update notice set title='"+title+"' ,content='"+content+"' where id="+id+"";
		dao.commOper(sql);
    	request.setAttribute("suc", "");
    	go("/admin/x-upnotice.jsp?id="+id, request, response);
	}
	//添加绿化
	if(ac.equals("addlh")){
		String sebei = request.getParameter("sebei");
		String feiyong = request.getParameter("feiyong");
		String wxtime = request.getParameter("wxtime");
		dao.commOper("insert into sebeix (sebei,feiyong,wxtime,type) values ('"+sebei+"','"+feiyong+"','"+wxtime+"','lh') ");
		request.setAttribute("suc", "");
    	go("/admin/addlh.jsp?", request, response);
	}
	//修改绿化
	if(ac.equals("updatelh")){
		String id = request.getParameter("id");
		String sebei = request.getParameter("sebei");
		String feiyong = request.getParameter("feiyong");
		String wxtime = request.getParameter("wxtime");
		dao.commOper("update sebeix set sebei='"+sebei+"',feiyong='"+feiyong+"',wxtime='"+wxtime+"' where id="+id);
		request.setAttribute("suc", "");
    	go("/admin/addlh.jsp?", request, response);
	}
	
	dao.close();
	out.flush();
	out.close();
}


	public void init() throws ServletException {
		// Put your code here
	}
	
	

}
